<?php

class Application_Form_Empleat extends Zend_Form {

    public $opciones;

    public function __construct($options = null) {
        parent::__construct($options);

        $this->setName('Nou empleat');

        $nom = new Zend_Form_Element_Text('nom');
        $nom->setLabel('Nom')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addErrorMessage("Camp obligatori!");


        $cognom = new Zend_Form_Element_Text('cognom');
        $cognom->setLabel('Cognom')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addErrorMessage("Camp obligatori!");

        $dni = new Zend_Form_Element_Text('dni');
        $dni->setLabel('DNI')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('regex', false, array('/[0-9]{8}[A-Z]/'))
                ->addErrorMessage("El DNI ha de tenir aquest format: 12345678X");

        $dept = new Zend_Form_Element_Select('departament');
        $dept->setMultiOptions($options)
                ->setRequired(true)->addValidator('NotEmpty', true);


        $submit = new Zend_Form_Element_Submit("submit");
        $submit->setLabel("Guardar");
        $submit->setAttrib('class', 'btn-success');

        $this->addElements(array($nom, $cognom, $dni, $dept, $submit));
    }

}

